package com.diandi.ddsb.bean;

/**
 * 
 * 体验金类型
 * 
 * @author liuxu
 * @since 2016年4月26日
 *
 */
public enum TasteType {
	FIXED_AMOUNT(0, "按固定额度"), INVEST_MULTIPLE(1, "按投资倍数"), INVEST_DAYS(2, "按期限"), INVEST_APR(3,
			"按预期年化"), INVEST_RATIO(4, "按返现比例");

	/**
	 * value
	 */
	private final String text;
	/**
	 * key
	 */
	private final int value;

	TasteType(int value, String text) {
		this.value = value;
		this.text = text;
	}

	public static TasteType getTextByValue(int value) {
		for (TasteType item : TasteType.values()) {
			if (item.getValue() == value) {
				return item;
			}
		}
		throw new RuntimeException(value + "不是合法的类型！");
	}

	public static TasteType getValueByText(String text) {
		for (TasteType item : TasteType.values()) {
			if (item.getText().equals(text)) {
				return item;
			}
		}
		throw new RuntimeException(text + "不是合法的类型！");
	}

	public String getText() {
		return text;
	}

	public int getValue() {
		return value;
	}
}
